from django.db import models
from PMSP.utils.base_model import BaseModel

# 1,广告类别表
class ContentCategory(BaseModel):
    name = models.CharField(max_length=20,verbose_name="列表名称")
    key = models.CharField(max_length=20,verbose_name="列表名称的键名")

    class Meta:
        db_table = "tb_content_category"
        verbose_name = "广告类别表"
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name

# 2，广告内容表
class Content(BaseModel):
    category = models.ForeignKey(ContentCategory,related_name="contents",on_delete=models.PROTECT,verbose_name="类别名")
    title = models.CharField(max_length=50,verbose_name="标题")
    url = models.CharField(max_length=300,verbose_name="内容链接地址")
    image = models.ImageField(null=True,blank=True,verbose_name="图片")
    text = models.TextField(null=True,blank=True,verbose_name="文本内容")
    sequence = models.IntegerField(verbose_name="排序方式")
    status = models.BooleanField(default=True,verbose_name="是否展示")

    class Meta:
        db_table = "tb_content"
        verbose_name = "广告内容表"
        verbose_name_plural = verbose_name
